<?php
include('action.abs.php');
class orders_mod extends action {
	function orders_mod() {
		parent :: action();
	}

   /*
    * 处理
    */
	function deal() {
		//

	}

	/*
    * 搜索
    */
	function search() {
		$name = urldecode(V('r:keyword', ''));
		$page = (int)V('g:page', 1);
		$each = (int)V('g:each', 15);
		$offset = ($page -1) * $each;
		$num = ($page -1) * $each;

		$rss = $rs = "";
		$rss = DR('ordersCom.getOrdersByName', '', $name, $offset, $each);

        foreach($rss['rst'] as $value) {
            $rs[$value['id']] = $value;
        }
        $count = count($rss['rst']);

		$pager = APP :: N('pager');
		$page_param = array('currentPage'=> $page, 'pageSize' => $each, 'recordCount' => $count, 'linkNumber' => 10);
		$pager->setParam($page_param);

		TPL :: assign('num', $num);
		TPL :: assign('pager', $pager->makePageForKeyWord('',array('keyword'=>urlencode($name))));
		TPL :: assign('count', $count);
		TPL :: assign('name', $name);
        TPL :: assign('list', $rs); 
        TPL :: display('mgr/orders_list', '', 0, false);
	}


	/*
     * 删除
     */
	function del() {
		$id = V('g:id', 0);
		if (!$id) {
			$this->_error('用户id不能为空', array('search'));
		}
		
		$p = DR('adminCom.getAdminById', '', $this->_getUid());	//获取当前操作者的数据
		if(!$p['rst']['isroot']) {
			$this->_error('您无权限删除', array('search'));
		}

		$rs = DR('ordersCom.delOrders', '', $id);
		if ($rs['rst']) {
			$this->_succ('操作已成功', array('search'));
		}
		
		$this->_error('删除失败',  array('search'));
	}
}
